package intro.databases.gtCarRental.ui.employee;

import java.sql.ResultSet;
import java.sql.SQLException;

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import intro.databases.gtCarRental.GTCRActivity;
import intro.databases.gtCarRental.R;

public class FrequentUsersReport extends GTCRActivity {
	LinearLayout table;

	@Override
	public void onCreate(Bundle b) {
		super.onCreate(b);
		setContentView(R.layout.frequent_users_report);
		
		table = (LinearLayout) findViewById(R.id.linearLayout_frequentUsersReport_table);
		
		ResultSet rS = dbConn.frequentUsers();
		try {
			while(rS.next()) {
				View v = getLayoutInflater().inflate(R.layout.frequent_users_report_tablerow, null);
				
				TextView username = (TextView) v.findViewById(R.id.textView_frequentUsersReport_username);
				TextView drivingPlan = (TextView) v.findViewById(R.id.textView_frequentUsersReport_drivingPlan);
				TextView numReservations = (TextView) v.findViewById(R.id.textView_frequentUsersReport_reservationsPerMonth);

				username.setText(rS.getString(1));
				drivingPlan.setText(rS.getString(2));
				numReservations.setText(rS.getString(3));
				
				table.addView(v);
			}
		} 
		catch (SQLException e) { e.printStackTrace(); }
	}

}
